package com.hhd.flow.engine.variable.impl;

import com.alibaba.fastjson.JSONObject;
import com.hhd.flow.engine.support.FlowFormSupportDelegate;
import com.hhd.flow.engine.variable.FlowVariableLoader;
import com.hhd.flow.engine.variable.FlowVariablesContainer;
import com.hhd.flow.entity.FlowProcessInstance;

import java.util.List;

public class DefaultFlowVariableLoader implements FlowVariableLoader {
    @Override
    public FlowVariablesContainer loadVariables(String formTypeId, String formId, FlowProcessInstance processInstance) {
        List<FlowVariablesContainer> flowVariablesContainers =
                FlowFormSupportDelegate.getInstance().loadVariables(formTypeId, formId, processInstance);
        return CompositeFlowVariablesContainer.forVariables(flowVariablesContainers);
    }

    @Override
    public FlowVariablesContainer loadVariableContainerForDefinition(String formTypeId, String formId, FlowProcessInstance processInstance) {
        List<FlowVariablesContainer> flowVariablesContainers =
                FlowFormSupportDelegate.getInstance().loadVariableContainerForDefinition(formTypeId, formId, processInstance);
        return CompositeFlowVariablesContainer.forVariables(flowVariablesContainers);
    }

    @Override
    public FlowVariablesContainer convertJSONToFormModel(String formTypeId, String formId, FlowProcessInstance processInstance, JSONObject formModel) {
        return FlowFormSupportDelegate.getInstance().convertJSONToFormModel(formTypeId, formId, processInstance, formModel);
    }
}
